package com.shop.adTag;

import com.shop.advertisement.service.IndexSlideAdService;
import com.shop.annotation.BeetlTagName;
import com.shop.pojo.LdbzIndexSlideAd;
import org.beetl.core.GeneralVarTagBinding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Scope("prototype")
@BeetlTagName("index_slide_tag")
public class IndexSlideTag extends GeneralVarTagBinding {
    private static Logger logger = LoggerFactory.getLogger(IndexSlideTag.class);
    @Autowired
    private IndexSlideAdService indexSlideAdService;

    @Override
    public void render() {
        logger.debug("获取首页轮播广告");
        List<LdbzIndexSlideAd> byRedis = indexSlideAdService.getIndexSlideAdByRedis();
        for (LdbzIndexSlideAd entity : byRedis) {
            this.binds(entity);
            this.doBodyRender();
        }
    }
}
